package com.conversationboard.database;


/**
 * Static class containing all the SQL for the site. Ultimately, I probably want to turn it all into stored procedures; however, they're new in MySql and I think that for two reasons, I won't do that
 * now: (1) they're not very mature and tested yet in MySql and (2) so that I can support pre V5 MySql if I want. Ultimately, stored procedures will be a good idea, if for no other reason than to
 * avoid dynamic binding.
 * 
 * @author Keith Watson
 */

public class Queries {

	private Queries() {
	}

	public static final String SEARCH_QUERY = "SELECT * FROM threads, messages WHERE (messages.threadid = threads.threadid) AND MATCH (body) AGAINST (?) GROUP BY threads.threadid LIMIT ?, 15";

	public static final String SEARCH_THREADS_QUERY = "SELECT *, MATCH (title) AGAINST (? IN BOOLEAN MODE) as relevance FROM threads WHERE MATCH (title, displayname) AGAINST (? IN BOOLEAN MODE) ORDER BY relevance DESC limit ?,15";

	public static final String SEARCH_THREADS_FOR_DISPLAY_NAME_QUERY = "SELECT *, MATCH (displayname) AGAINST (? IN BOOLEAN MODE) as relevance FROM threads WHERE MATCH (title, displayname) AGAINST (? IN BOOLEAN MODE) ORDER BY relevance DESC limit ?,15";

	public static final String SEARCH_COMBINED_QUERY = "SELECT *, MATCH (title, displayname) AGAINST (? IN BOOLEAN MODE) as relevance FROM threads WHERE MATCH (title, displayname) AGAINST (? IN BOOLEAN MODE) ORDER BY relevance DESC limit ?,15";

	public static final String GET_THREADS_WITH_NEW_ANSWERS_FOR_BOARD_QUERY = "SELECT * FROM threads WHERE boardid=? ORDER BY lastupdated DESC LIMIT ?";

	public static final String GET_THREADS_WITH_NEW_ANSWERS_QUERY = "SELECT * FROM threads ORDER BY lastupdated DESC LIMIT ?";

	public static final String GET_THREADS_LAST_UPDATED_ON = "SELECT * FROM threads WHERE (lastupdated > ? AND lastupdated < ?) AND boardid=? ORDER BY lastupdated DESC";

	public static final String GET_THREAD = "SELECT * FROM threads WHERE (boardid=? AND threadid=?)";

	public static final String GET_USERID_FROM_MESSAGE = "SELECT userid FROM messages WHERE boardid=? AND threadid=? AND messageid=?";

	public static final String GET_BOARD_QUERY = "SELECT * FROM boards WHERE boardid=?";

	public static final String INSERT_THREAD_AND_OVERRIDE_DATE_QUERY = "INSERT INTO threads (boardid, threadid, title, displayname, loginid, lastupdated, latestmessageid, poll, pollclosingdate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";

	public static final String INSERT_MESSAGE_QUERY = "INSERT INTO messages (boardid, threadid, messageid, userid, displayname, ipaddress, body) VALUES (?, ?, ?, ?, ?, ?, ?)";

	public static final String UPDATE_POST_COUNT = "UPDATE users SET postcount=postcount+1 WHERE loginid=?";

	public static final String GET_RECENT_QUESTIONS_QUERY = "SELECT * FROM threads WHERE (boardid=?) ORDER BY threadid DESC LIMIT ?, ?";

	public static final String GET_ALL_RECENT_QUESTIONS_QUERY = "SELECT * FROM threads ORDER BY timestamp DESC LIMIT ?, ?";

	public static final String GET_ALL_BOARDS_QUERY = "SELECT * FROM boards ORDER BY name";

	/* I have removed the ORDER BY clause here, as the table is indexed in message ID order and it makes a big difference to query performance. I
	 * don't think it's guaranteed to come back in index order, but clearly it would make no sense not to; hence, leaving the comment in, should
	 * anything look strange. */

	public static final String GET_MESSAGES_QUERY = "SELECT * FROM messages WHERE (boardid=? and threadid=?)";

	public static final String GET_USER_QUERY = "SELECT * FROM users, userroles WHERE (users.loginid=?) AND (users.loginid=userroles.loginid)";

	public static final String GET_DISPLAYNAME_QUERY = "SELECT displayname FROM users WHERE displayname=?";

	public static final String CHECK_IF_USER_EXISTS_QUERY = "SELECT * FROM users WHERE loginid=? OR displayname=?";

	public static final String INSERT_USER_QUERY = "INSERT INTO users (loginid, displayname, creationdate, password, timezone, stylesheet, ipaddress) VALUES (?, ?, ?, ?, ?, ?, ?)";

	public static final String INSERT_USER_ROLE_QUERY = "INSERT INTO userroles (loginid, role) VALUES (?, ?)";

	public static final String UNLOCK_TABLES_QUERY = "UNLOCK TABLES";

	public static final String GET_UNANSWERED_QUESTIONS_QUERY = "SELECT * FROM threads WHERE (boardid=? AND unanswered=true) ORDER BY boardid, threadid DESC LIMIT ?, ?";

	public static final String UPDATE_USER_SITE_ADMIN = "UPDATE userroles SET role='siteadmin' WHERE (loginid=?)";

	public static final String SET_THREAD_ANSWERED = "UPDATE threads SET unanswered=false WHERE (boardid=? AND threadid=?)";

	public static final String SET_LAST_UPDATED_TIMESTAMP_CURRENT = "UPDATE threads SET lastupdated=CURRENT_TIMESTAMP WHERE (boardid=? AND threadid=?)";

	public static final String STORE_BOARD_ADMINS = "UPDATE userroles SET boards=? WHERE loginid=?";

	public static final String MAKE_BOARD_ADMIN = "UPDATE userroles SET role='boardadmin' WHERE loginid=?";

	public static final String ADMIN_LOCK_THREAD = "UPDATE threads SET locked=true WHERE (boardid=? AND threadid=?)";

	public static final String ADMIN_UNLOCK_THREAD = "UPDATE threads SET locked=false WHERE (boardid=? AND threadid=?)";

	public static final String ADMIN_DELETE_THREAD = "UPDATE threads SET deleted=true, reindex=true WHERE (boardid=? AND threadid=?)";

	public static final String ADMIN_DELETE_MESSAGES = "UPDATE messages SET reindex=true, deleted=true WHERE (boardid=? AND threadid=?)";

	public static final String ADMIN_UNDELETE_MESSAGES = "UPDATE messages SET deleted=false, reindex=true WHERE (boardid=? AND threadid=?)";

	public static final String ADMIN_PERMANENTLY_DELETE_THREAD = "DELETE FROM threads WHERE (boardid=? AND threadid=?)";

	public static final String ADMIN_PERMANENTLY_DELETE_MESSAGES = "DELETE FROM messages WHERE (boardid=? AND threadid=?)";

	public static final String ADMIN_UNDELETE_THREAD = "UPDATE threads SET deleted=false, reindex=true WHERE (boardid=? AND threadid=?)";

	public static final String ADMIN_MAKE_THREAD_WORKSAFE = "UPDATE threads SET worksafe=true WHERE (boardid=? AND threadid=?)";

	public static final String ADMIN_MAKE_THREAD_WORKUNSAFE = "UPDATE threads SET worksafe=false WHERE (boardid=? AND threadid=?)";

	public static final String ADMIN_DELETE_MESSAGE = "UPDATE messages SET deleted=true, reindex=true WHERE (boardid=? AND threadid=? AND messageid=?)";

	public static final String ADMIN_UNDELETE_MESSAGE = "UPDATE messages SET deleted=false, reindex=true WHERE (boardid=? AND threadid=? AND messageid=?)";

	public static final String ADMIN_UPDATE_MESSAGE = "UPDATE messages SET body=?, reindex=true WHERE (boardid=? AND threadid=? AND messageid=?)";

	public static final String GET_MESSAGE = "SELECT * FROM messages WHERE (boardid=? AND threadid=? AND messageid=?)";

	public static final String ADMIN_INSERT_BOARD = "INSERT INTO boards (boardid, name, description, popularboard, access, requireregistration, hidden, adminsaddusers, allowpolls, noindex, logadminactions, sandboxdays, numberofnewposts) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

	public static final String ADMIN_UPDATE_BOARD = "UPDATE boards SET name=?, description=?, popularboard=?, access=?, requireregistration=?, hidden=?, adminsaddusers=?, allowpolls=?, noindex=?, logadminactions=?, sandboxdays=?, numberofnewposts=? WHERE boardid=?";

	public static final String DEAUTHORISE_ALL_USERS_FOR_BOARD = "DELETE FROM boardmembership WHERE boardid=?";

	public static final String ADMIN_UPDATE_THREAD_TITLE = "UPDATE threads SET title=?, reindex=true WHERE boardid=? AND threadid=?";

	/*
	 * Was originally ordering here, but don't bother, as it's much faster not to
	 */

	public static final String SEARCH_BY_DATE = "SELECT * FROM threads WHERE (lastupdated > ?) AND (lastupdated < ?)";

	public static final String SEARCH_BY_USER = "SELECT boardid, threadid, body, timestamp, deleted FROM messages WHERE (displayname = ?) AND (timestamp > ?) AND (timestamp < ?) LIMIT ?, 10";

	public static final String ADMIN_USER_BAN = "INSERT INTO banned (pattern, text, banneduntil, regularexpression, boardid) VALUES (?, ?, ?, ?, ?)";

	public static final String ADMIN_USER_UNBAN = "DELETE FROM banned WHERE pattern=? LIMIT 1";

	public static final String GET_BANNED_USER_BY_ID = "SELECT * FROM banned WHERE id=?";

	public static final String ADMIN_USER_UNBAN_BY_ID = "DELETE FROM banned WHERE id=? LIMIT 1";

	public static final String ADMIN_DELETE_BANS = "DELETE FROM banned WHERE pattern=?";

	public static final String ADMIN_DELETE_EXPIRED_BANS = "DELETE FROM banned WHERE banneduntil < CURRENT_DATE()";

	public static final String GET_BANNED_USERS = "SELECT * FROM banned";

	public static final String PERMANENTLY_DELETE_BOARD = "DELETE FROM boards WHERE boardid=?";

	public static final String PERMANENTLY_DELETE_THREADS = "DELETE FROM threads WHERE boardid=?";

	public static final String PERMANENTLY_DELETE_MESSAGES = "DELETE FROM messages WHERE boardid=?";

	public static final String WRITE_TO_ERROR_LOG = "INSERT INTO log (timestamp, message, loginid, type) VALUES (?, ?, ?, ?)";

	public static final String MOVE_THREAD_TO_NEW_BOARD = "UPDATE threads SET boardid=?, threadid=?, indexed=false WHERE boardid=? AND threadid=?";

	public static final String MOVE_THREAD_MESSAGES_TO_NEW_BOARD = "UPDATE messages SET boardid=?, threadid=?, indexed=false WHERE boardid=? AND threadid=?";

	public static final String GET_FIRST_MESSAGE_IN_THREAD_MESSAGEID = "SELECT MIN(messageid) AS messageid FROM messages WHERE boardid=? and threadid=?";

	public static final String MOVE_POLL_ITEMS_TO_NEW_BOARD = "UPDATE polls SET boardid=?, threadid=? WHERE boardid=? AND threadid=?";

	public static final String CHANGE_IMAGE_DISPLAY_PREFERENCES = "UPDATE users SET showimages=? WHERE loginid=?";

	public static final String CHANGE_TIMEZONE_PREFERENCE = "UPDATE users SET timezone=? WHERE loginid=?";

	public static final String INSERT_POLL_OPTIONS = "INSERT INTO polls (boardid, threadid, optionid, optiontext, votecount) VALUES (?, ?, ?, ?, 0)";

	public static final String VOTE = "UPDATE polls SET votecount = votecount + 1 WHERE boardid=? AND threadid=? AND optionid=?";

	public static final String GET_POLL_OPTIONS = "SELECT * FROM polls WHERE boardid=? AND threadid=?";

	public static final String GET_POLL_RESULTS = "SELECT * FROM polls WHERE boardid=? AND threadid=? ORDER BY votecount DESC";

	public static final String GET_LOG = "SELECT * FROM log";

	public static final String GET_LOG_SUBSET = "SELECT * FROM log WHERE type=?";

	public static final String CHANGE_PASSWORD = "UPDATE users SET password=? WHERE loginid=?";

	public static final String UPDATE_PROPERTY = "UPDATE propertybag SET propertyvalue=? WHERE propertyname=?";

	public static final String INSERT_INTO_PROPERTY_BAG = "INSERT INTO propertybag (propertyname, propertyvalue) VALUES (?, ?)";

	public static final String GET_FROM_PROPERTY_BAG = "SELECT * FROM propertybag WHERE propertyname=?";

	public static final String GET_THREADS_IN_MONTH = "SELECT * FROM threads WHERE (timestamp >= ? AND timestamp < ? AND deleted = false) LIMIT ?,100";

	public static final String UPDATE_PREFERENCES = "UPDATE users SET preferences=? WHERE loginid=?";

	public static final String GET_SITE_ADMINS = "SELECT loginid FROM userroles WHERE role='siteadmin'";

	public static final String GET_BOARD_ADMINS = "SELECT * FROM userroles WHERE role='boardadmin'";

	public static final String REVOKE_BOARD_PRIVILEGES = "UPDATE userroles SET role='user', boards=null WHERE loginid=?";

	public static final String GET_RECENTLY_REGISTERED_USERS = "SELECT loginid FROM users where (creationdate > TIMESTAMPADD(DAY, -7, CURRENT_TIMESTAMP)) ORDER BY creationdate ASC";

	public static final String GET_RECENTLY_REGISTERED_USERS_PASSWORDS = "SELECT password FROM users where (DATE(creationdate) >= DATE_SUB(CURRENT_DATE, INTERVAL 3 DAY))";

	public static final String GET_NUMBER_OF_REGISTERED_USERS = "SELECT COUNT(*) AS count FROM users";

	public static final String SET_USER_DISPLAY_NAME = "UPDATE users SET displayname=? WHERE loginid=?";

	public static final String USER_STORE_BOOKMARKS = "UPDATE users SET bookmarks=? WHERE loginid=?";

	public static final String USER_STORE_UNREAD_MESSAGE_MAP = "UPDATE users SET threadpositions=? WHERE loginid=?";

	public static final String USER_STORE_PROFILE = "UPDATE users SET profile=? WHERE loginid=?";

	public static final String USER_STORE_PRIVILEGE_LIST = "UPDATE users SET privilegelist=? WHERE loginid=?";

	public static final String REMOVE_BAN_REQUEST_VOTES = "DELETE FROM banrequests WHERE banloginid=?";

	public static final String GET_BAN_REQUESTS_FOR_USER = "SELECT * FROM banrequests WHERE loginid=?";

	public static final String RECORD_BAN_REQUEST = "INSERT INTO banrequests (loginid, ipaddress, banloginid, boardid, threadid, messageid, body) VALUES (?, ?, ?, ?, ?, ?, ?)";

	public static final String GET_MAXIMUM_THREAD_ID = "SELECT MAX(threadid) AS maximum FROM threads";

	public static final String GET_MAXIMUM_MESSAGE_ID = "SELECT MAX(messageid) AS maximum FROM messages";

	public static final String GET_EARLIEST_THREAD = "SELECT DATE(MIN(timestamp)) as timestamp from threads";

	public static final String GET_DISTINCT_USERS_FROM_BOARD = "SELECT DISTINCT userid FROM messages WHERE boardid=?";

	public static final String MAKE_BOARD_PRIVATE = "UPDATE BOARDS SET private=true WHERE boardid=?";

	public static final String GET_BOARD_MEMBERSHIP = "SELECT * FROM boardmembership WHERE loginid=?";

	public static final String GRANT_BOARD_MEMBERSHIP = "INSERT INTO boardmembership (loginid, boardid) VALUES (?, ?)";

	public static final String IS_USER_SUBSCRIBED_TO_BOARD = "SELECT count(*) AS count FROM subscriptions WHERE loginid=? AND boardid=?";

	public static final String SUBSCRIBE_USER_TO_BOARD = "INSERT INTO subscriptions (loginid, boardid) VALUES (?, ?)";

	public static final String GET_BOARD_MEMBERS = "SELECT * FROM boardmembership WHERE boardid=?";

	public static final String REMOVE_USER_FROM_CLOSED_BOARD = "DELETE FROM boardmembership WHERE loginid=? AND boardid=?";

	public static final String UPDATE_USER_LAST_LOGGED_IN_AND_IP_ADDRESS = "UPDATE users SET lastloggedin=?, ipaddress=? WHERE loginid=?";

	public static final String GET_DEAD_USERS = "SELECT loginid FROM users WHERE DATE(lastloggedin) != '0000-00-00' AND lastloggedin < TIMESTAMPADD(DAY, -180, CURRENT_TIMESTAMP) AND permanent = false";

	public static final String DELETE_USER = "DELETE FROM users WHERE loginid=?";

	public static final String DELETE_USERROLE = "DELETE FROM userroles WHERE loginid=?";

	public static final String GET_SUPERSET_OF_SUBSCRIBED_BOARDS = "SELECT DISTINCT (boardid) FROM subscriptions";

	public static final String GET_SUBSCRIPTIONS = "SELECT * FROM subscriptions";

	public static final String CLEAR_LOG = "DELETE FROM log WHERE type=?";

	public static final String CLEAR_OLD_USER_LOGS = "DELETE FROM log WHERE timestamp < TIMESTAMPADD(DAY, -30, CURRENT_TIMESTAMP) AND type='USER'";

	public static final String GET_USER_SUBSCRIPTIONS = "SELECT boardid FROM subscriptions WHERE loginid=?";

	public static final String UNSUBSCRIBE_USER = "DELETE FROM subscriptions WHERE loginid=? AND boardid=?";

	public static final String SHOW_STATUS = "SHOW STATUS";

	public static final String GET_ALL_THREAD_TITLES = "SELECT boardid, threadid, title, latestmessageid, deleted FROM threads LIMIT ?, ?";

	public static final String FIND_SOCKPUPPETS = "SELECT loginid, displayname, password FROM users WHERE password IN (SELECT password FROM users GROUP BY password HAVING COUNT(password) > 1 ORDER BY COUNT(password) DESC) ORDER BY password";

	public static final String MORE_THAN_ONE_PASSWORD = "SELECT password FROM users GROUP BY password HAVING COUNT(password) > 1";

	public static final String MORE_THAN_ONE_IPADDRESS = "SELECT ipaddress FROM users GROUP BY ipaddress HAVING COUNT(ipaddress) > 1";

	public static final String GET_ALL_USERS = "SELECT loginid, displayname, originaldisplayname, password, ipaddress, creationdate, lastloggedin, permanent FROM users";

	public static final String GET_ALL_USER_NAMES = "SELECT loginid, displayname, originaldisplayname FROM users";

	public static final String SEARCH_USER_NAMES = "SELECT id, loginid, displayname, originaldisplayname FROM users WHERE loginid LIKE ? OR displayname LIKE ? OR originaldisplayname LIKE ?";

	public static final String GET_DISTINCT_IPS_IN_LAST_X_DAYS = "SELECT DISTINCT(ipaddress) FROM messages WHERE userid=? AND timestamp > TIMESTAMPADD(DAY, -?, CURRENT_TIMESTAMP)";

	public static final String GET_DISTINCT_USERS_FOR_IP_IN_LAST_X_DAYS = "SELECT DISTINCT(userid), displayname FROM messages WHERE ipaddress=? AND timestamp > TIMESTAMPADD(DAY, -?, CURRENT_TIMESTAMP)";

	public static final String SHOW_PROCESS_LIST = "SHOW FULL PROCESSLIST";

	public static final String RUNSTATS_THREADS = "ANALYZE TABLE threads";

	public static final String RUNSTATS_MESSAGES = "ANALYZE TABLE messages";

	public static final String RUNSTATS_USERS = "ANALYZE TABLE users";

	public static final String RUNSTATS_USERROLES = "ANALYZE TABLE userroles";

	public static final String RUNSTATS_BOARDS = "ANALYZE TABLE boards";

	public static final String RUNSTATS_POLLS = "ANALYZE TABLE polls";

	public static final String RUNSTATS_BOARD_MEMBERSHIP = "ANALYZE TABLE boardmembership";

	public static final String WRITE_TO_ADMIN_LOG = "INSERT INTO adminlog (boardid, loginid, displayname, action) VALUES (?, ?, ?, ?)";

	public static final String RECORD_REASON_ON_ADMIN_LOG = "UPDATE adminlog SET reason=? WHERE id=?";

	public static final String GET_ADMIN_LOG = "SELECT * FROM adminlog ORDER BY id DESC LIMIT ?, ?";

	public static final String GET_ADMIN_LOG_ITEM = "SELECT * FROM adminlog WHERE id=?";

	public static final String STORE_OLD_USER_NAME = "UPDATE users SET originaldisplayname=? WHERE loginid=?";

	public static final String GET_BOOKMARKS = "SELECT * FROM bookmarks WHERE userid=?";

	public static final String INSERT_BOOKMARK = "INSERT INTO bookmarks (userid, boardid, threadid, messageid) VALUES (?, ?, ?, ?)";

	public static final String UPDATE_BOOKMARK = "UPDATE bookmarks SET messageid=? WHERE userid=? AND boardid=? AND threadid=?";

	public static final String DELETE_BOOKMARK = "DELETE FROM bookmarks WHERE userid=? AND boardid=? AND threadid=?";

	public static final String YELLOW_CARD_USER = "UPDATE users SET yellowcard=CURRENT_TIMESTAMP, reason=? WHERE id=?";

	public static final String IDENTIFY_USER = "SELECT displayname, originaldisplayname FROM users WHERE loginid=?";

	public static final String COUNT_THREADS = "SELECT COUNT(*) AS total FROM threads";

	public static final String UPDATE_BAN_COUNT = "UPDATE users SET bancount = bancount + 1 WHERE id=?";

	public static final String UPDATE_LATEST_MESSAGE_ID = "UPDATE threads SET latestmessageid=? WHERE boardid=? AND threadid=?";

	public static final String UPDATE_MOVED_THREAD_BOOKMARKS = "UPDATE bookmarks SET boardid=?, threadid=? WHERE boardid=? AND threadid=?";

	public static final String GET_PASSWORD_FOR_USER = "SELECT password FROM users WHERE loginid=?";

	public static final String GET_USERS_WITH_SAME_PASSWORD = "SELECT loginid, displayname, originaldisplayname, creationdate, lastloggedin, logincount, postcount FROM users WHERE password=?";

	public static final String UPDATE_STYLESHEET = "UPDATE users SET stylesheet=? WHERE loginid=?";

	public static final String GET_MY_SUGGEST_BANS = "SELECT banloginid, id FROM banrequests WHERE loginid=?";

	public static final String COUNT_SUGGEST_BANS = "SELECT COUNT(*) AS total FROM banrequests WHERE banloginid=?";

	public static final String GET_INDIVIDUAL_BAN_REQUEST_REPORT = "SELECT banrequests.loginid, users.originaldisplayname, users.displayname, creationdate, logincount, postcount, banrequests.timestamp, CONCAT(boardid, '-', threadid, '-', messageid), body, banrequests.id FROM banrequests, users WHERE banloginid=? AND users.loginid = banrequests.loginid ORDER BY postcount DESC";

	public static final String GET_YELLOWCARD_REPORT = "SELECT loginid, timestamp, reason, message, CONCAT(boardid, '-', threadid, '-', messageid), modloginid FROM yellowcards WHERE loginid=?";

	public static final String GET_ALL_YELLOWCARDS = "SELECT loginid, timestamp, reason, message, CONCAT(boardid, '-', threadid, '-', messageid), modloginid FROM yellowcards ORDER BY timestamp DESC";

	public static final String RECORD_YELLOWCARD_LOG = "INSERT INTO yellowcards (loginid, reason, boardid, threadid, messageid, message, modloginid) VALUES (?, ?, ?, ?, ?, ?, ?)";

	public static final String UPDATE_USER_LAST_LOGGED_IN = "UPDATE users SET lastloggedin=NOW(), ipaddress=? WHERE loginid=?";

	public static final String UPDATE_USER_LAST_LOGGED_IN_AND_LOGIN_COUNT = "UPDATE users SET lastloggedin=NOW(), ipaddress=?, logincount = logincount + 1 WHERE loginid=?";

	public static final String REMOVE_SUGGEST_BAN = "DELETE FROM banrequests WHERE id=?";

	public static final String LAST_FIFTY_SUGGEST_BANS = "SELECT loginid, banloginid, body, CONCAT(boardid, '-', threadid, '-', messageid), timestamp FROM banrequests ORDER BY timestamp DESC LIMIT 50";

	public static final String SUGGEST_BANS_FROM_USER = "SELECT banrequests.banloginid, displayname, users.originaldisplayname, body, CONCAT(boardid, '-', threadid, '-', messageid), timestamp FROM banrequests, users WHERE banrequests.loginid=? AND users.loginid = banrequests.banloginid";

	public static final String SET_USER_PERMANENT = "UPDATE users SET permanent=? WHERE loginid=?";

	public static final String INSERT_FILE = "INSERT INTO fileuploads (loginid, originalfilename, size, filename, image) VALUES (?, ?, ?, ?, ?)";

	public static final String GET_MY_FILE_UPLOADS = "SELECT * FROM fileuploads WHERE loginid=? ORDER BY timestamp DESC LIMIT ?, ?";

	public static final String DELETE_ALL_BOOKMARKS = "DELETE FROM bookmarks WHERE userid=?";

	public static final String INDEX_THREAD = "UPDATE threads SET deindexed = FALSE WHERE boardid=? AND threadid=?";

	public static final String DEINDEX_THREAD = "UPDATE threads SET deindexed = TRUE WHERE boardid=? AND threadid=?";

	public static final String MOVE_BAN_REQUESTS = "INSERT INTO banrequestsarchive SELECT * FROM banrequests WHERE banloginid=?";
	
	public static final String UPDATE_DISPLAY_NAMES = "UPDATE users SET displayname=?, originaldisplayname=? WHERE id=?";
}